package com.example.demo.service.imp;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.entity.Group;
import com.example.demo.entity.Shoppingcart;
import com.example.demo.mapper.GroupMapper;
import com.example.demo.mapper.ShoppingcartMapper;
import com.example.demo.service.GroupService;
import com.example.demo.service.ShoppingcartService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShoppingcartServiceImp implements ShoppingcartService {
    @Resource
    private ShoppingcartMapper shoppingcartMapper;



    @Override
    public void insert(Shoppingcart shoppingcart) {
        shoppingcartMapper.insert(shoppingcart);
    }

    @Override
    public void updateById(Shoppingcart shoppingcart) {
        shoppingcartMapper.updateById(shoppingcart);
    }

    @Override
    public void deleteById(Long id) {
        shoppingcartMapper.deleteById(id);
    }

    @Override
    public Page<Shoppingcart> selectPage(Integer pageNum, Integer pageSize, String search) {
        LambdaQueryWrapper<Shoppingcart> wrapper = Wrappers.<Shoppingcart>lambdaQuery();
//        if(StrUtil.isNotBlank(search)){
//
//        }
        return shoppingcartMapper.selectPage(new Page<>(pageNum, pageSize),wrapper);
    }

    @Override
    public Object selectById(Integer flowerId,Integer userId) {
        return shoppingcartMapper.selectById(flowerId,userId);
    }

    @Override
    public void updateNum(Integer flowerId, Integer userId, int quantity) {
        shoppingcartMapper.updateNum(flowerId,userId,quantity);
    }

    @Override
    public List<Shoppingcart> selectByUserId(String userId) {
        return shoppingcartMapper.selectByUserId(userId);
    }

    @Override
    public void updateQuantity(String userId, String flowerId, Integer quantity) {
        shoppingcartMapper.updateQuantity(userId,flowerId,quantity);
    }

    @Override
    public List<Shoppingcart> selectChecked(String userId) {
        return shoppingcartMapper.selectChecked(userId);
    }

    @Override
    public void deleteByUserId(String userId) {
        shoppingcartMapper.deleteByUserId(userId);
    }


}
